package thefirst.controller;

import java.sql.SQLException;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import thefirst.LessonSerch.model.LessonBoardService;
import thefirst.LessonSerch.model.LessonBoardVO;

@Controller
public class LessonBoardController {
	@Resource(name = "lessonBoardServiceImpl")
	private LessonBoardService lessonBoardService;

	@RequestMapping("/writeLessonBoard.do")
	public ModelAndView writeLessonBoard(LessonBoardVO lbvo, HttpSession session)
			throws SQLException {
		return new ModelAndView("redirect:/showLessonBoardInfoNoHits.do?no="
				+ lbvo.getNo());
	}
/**
 * 자신이 쓴 글을 조회
 * @param no
 * @return
 * @throws SQLException
 */
	@RequestMapping("/showLessonBoardInfoNoHits.do")
	public ModelAndView showLessonBoardInfoNoHits(int no) throws SQLException {
		return new ModelAndView("LessonBoard/", "lbvo",
				lessonBoardService.showLessonBoardInfoNoHits(no));
	}
/**
 * 리스트를 보여준다.
 * @param pageNo
 * @return
 * @throws SQLException
 */
	@RequestMapping("/lessonBoardSerch.do")
	public ModelAndView lessonBoardList(String pageNo,HttpSession session) throws SQLException{
		if(session!=null)
		return new ModelAndView("LessonBoard/lessonBoardList.lessonBoard","list",lessonBoardService.getLessonBoardList(pageNo));
		return null;
	}
	/**
	 * 글쓰기 페이지로 이동
	 */
	@RequestMapping("/writeLessonBoard.do")
	public ModelAndView writeLessonBoard() throws SQLException{
		
		return null;
	}
}
